package com.investmenttechnologyservices.model;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.investmenttechnologyservices.util.RandomStringId;

public class Firm extends EntityHolder{
	//private String id;
	//private String name;
	//private Long maxUsers = 1L;
	//private Long maxAccounts = 5L;
	//private Long nextTradeId = 1L;
	
	public Firm(Entity entity) {
		super(entity);
	}
	
	public Firm(String id) {
	    super("firm", id);
	}

	public Firm(String name, Long maxUsers, Long maxAccounts) {
		this(RandomStringId.setId(36), name, maxUsers, maxAccounts);
	}
	
	public Firm(String stringId, String name, Long maxUsers, Long maxAccounts) {
		this(stringId);
		setName(name);
		setMaxUsers(maxUsers);
		setMaxAccounts(maxAccounts);
		setNextTradeId(1L);
	}

	public Key getKey() {return super.getKey();}
	
	public String getName() {
		return (String) getProperty("name");
	}

	public void setName(String name) {
		setProperty("name", name);
	}
	
	public void setMaxUsers(Long maxUsers) {setProperty("maxUsers", maxUsers);}
	public Long getMaxUsers() {
		Long maxUsers = (Long)getProperty("maxUsers");
		if (maxUsers == null) {
			maxUsers = 1L;
		}
		return maxUsers;}

	public void setMaxAccounts(Long maxAccounts) {setProperty("maxAccounts", maxAccounts);}
	public Long getMaxAccounts() {
		Long maxAccounts = (Long)getProperty("maxAccounts");
		if (maxAccounts == null) {
			maxAccounts = 1L;
		}
		return maxAccounts;}

	public void setNextTradeId(Long nextTradeId) {setProperty("nextTradeId",nextTradeId);}
	public Long getNextTradeId() {
		Long nextTradeId = (Long)getProperty("nextTradeId");
		if (nextTradeId == null) {
			nextTradeId = 1L;
		}
		return nextTradeId;}

}
